<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>出入库明细报表</title>
    <jsp:include page="/WEB-INF/view/commons/css.jsp" />
</head>
<body >
<div id="main-container" class="container-fluid">
    <form action="reportCheck/dolist" method="post" name="searchForm" id="searchForm" role="form" class="form-horizontal">
             <div class="form-group">
                    <label class="col-sm-1 control-label">物资名称：</label>
                    <div class="col-md-4">
                        <input type="text" class="form-control" id="materialsName" name="materialsName" value="${entity.materialsName}" placeholder="物资名称">
                    </div>
                    <label class="col-sm-1 control-label">单据号：</label>
                    <div class="col-md-4">
                		<input type="text" class="form-control" id="checkCode" name="checkCode" value="${entity.checkCode}" placeholder="单据号">                           
                    </div>
            </div>
            
            <div class="form-group">
                    <label class="col-sm-1 control-label">经办人：</label>
                    <div class="col-md-4">
                                <input type="text" class="form-control" id="agentName" name="agentName" value="${entity.agentName}" placeholder="经办人">
                    </div>
					<!-- <label class="inline col-md-4"> 
						
					</label> -->
					<label class="col-sm-1 control-label">时间：</label>
						<div class="col-md-4">
							<input type="text" class="span1 Wdate" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd', maxDate:'#F{$dp.$D(\'endAddTime\')}'})" id="beginAddTime" name="beginAddTime" value="${searchEntity.beginAddTime}" placeholder="开始时间" /> 至 
							<input type="text" class="span1 Wdate" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd', minDate:'#F{$dp.$D(\'beginAddTime\')}'})" id="endAddTime" name="endAddTime" value="${searchEntity.endAddTime}" placeholder="结束时间" />
						</div>
			</div>
            
           	
			<!-- <div class="form-group">
				
			</div>	 -->
			<div class="row">
        		<div class="col-md-10">
            		<p>	
            			<a id="export_menu_btn" onclick = exportexcal() class="btn btn-sm btn-pink"><i class="fa fa-file-excel-o icon-share"></i> 导出</a>
						<button id="searchBtn" type="button" class="btn btn-sm btn-info"><i class="fa fa-search"></i> 查询</button>
						<input id="diffStock" name="diffStock" type="checkbox" class="ace" onchange="showDiff();" value="0" /> <span class="lbl"> 只显示差异库存</span>
			    	</p>
        		</div>
    		</div>		
    </form>
    
    <form id= "exportexcalform" method=post action="${ctx}reportCheck/export" target="_blank" >
					<input type="hidden" name="materialsName"  />
					<input type="hidden" name="checkCode"  />
					<input type="hidden" name="agentName"  />
					<input type="hidden" name="beginAddTime"  />
					<input type="hidden" name="endAddTime"  />
					<input type="hidden" name="diffStock"  />
	</form>
    
    <table id="table_data" class="table table-striped table-bordered table-hover">
        <thead>
        
        <tr>
            <th width="10%">单据号</th>
            <th width="10%">物资编号</th>
            <th width="10%">物资名称</th>
            <th width="8%">规格</th>
            <th width="6%">单位</th>
            <th width="8%">原库存</th>
            <th width="8%">盘点库存</th>
            <th width="8%">经办人</th>
            <th width="18%">备注</th>
            <th width="15%">盘点时间</th>
           	<th width="6%">操作</th>
        </tr>
         
        </thead>
        <tbody>
        </tbody>
    </table>
</div>
<!-- 返回顶部  -->
<a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
    <i class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
</a>
<!-- script start -->
<jsp:include page="/WEB-INF/view/commons/js.jsp" />
<script type="text/javascript">
    $(document).ready(function(e) {
        var table = $("#table_data").dataTable({
            ajax: function(data, callback, settings){
                tableAjax($("#searchForm"),data, callback, settings);
            },
            //列表表头字段
            columns: [
                { "data": "checkCode",name:"check_code",orderable:false },
                { "data": "materialsCode",name:"materials_code",orderable:false },
                { "data": "materialsName",name:"materials_name",orderable:false },
                { "data": "specification",name:"specification",orderable:false },
                { "data": "unitStr",name:"unit",orderable:false },
                { "data": "systemStock",name:"system_stock",orderable:false },
                { "data": "checkStock",
                	
                	"render": function (data, type, row, meta) {  
                       var a = "";  
                           if(row.diffStock == "1") {  
                               var a = '<span style="color:#000000">'+row.checkStock+'</span>';  
                           }else if(row.diffStock == "2"){  
                               var a = '<span style="color:#ff0000">'+row.checkStock+'</span>';  
                           }else if(row.diffStock == "3") {  
                               var a = '<span style="color:#00ff33">'+row.checkStock+'</span>';  
                           }else{  
                               var a = '<span>'+row.checkStock+'</span>';  
                           }  
                           return a;  
                       },orderable:false  
                
                },
                { "data": "agentName",name:"agent_name",orderable:false },
                { "data": "remark",name:"remark",orderable:false },
                { "data": "checkTimeStr",name:"check_time",orderable:false },
                {
                    "data": "action",
                    "render": function ( data, type, row, meta ) {
                    	var info = "<a href='javacript:void(0);' onclick=\"show_in('"+row.id+"')\" >查看</a>"
                        return info;
                    },orderable:false,
                }
        ]
    }).api();

        //查询条件
        $("#searchForm").submit(function(){
            table.ajax.reload();
            return false;
        });
    });
    
    //showdiff
    function showDiff(){
    	var isChecked = $('#diffStock').prop('checked'); 
    	if(isChecked){
    		$("#diffStock").val("1");
    	}else{
    		$("#diffStock").val("0");
    	}
    	$('#searchBtn').click();
    }
    
    
  //查看盘点计划表签署过后的文件
    function show_in(id){
        var option={
            url:"appCheckPlan/checkPrintSigned/"+id,
            title:"查看盘点计划表",
            width:"60%",
            height:"90%"
        };
        openIframe(option);
    }
    
  //点击导出 将页面数据加载到表单中
	function exportexcal(){
		if($.trim($("#materialsName").val())=='' && $.trim($("#checkCode").val())=='' && $.trim($("#agentName").val())=='' && $.trim($("#beginAddTime").val())=='' && $.trim($("#endAddTime").val())=='' && $.trim($("#diffStock").val())== '0' ){
			layer.msg("没有任何筛选条件，系统无法筛选结果，导出动作被取消！");
			return false;
		} 
		$('#exportexcalform input[name="materialsName"]').val($.trim($("#materialsName").val()));
		$('#exportexcalform input[name="checkCode"]').val($.trim($("#checkCode").val()));
		$('#exportexcalform input[name="agentName"]').val($.trim($("#agentName").val()));
		$('#exportexcalform input[name="beginAddTime"]').val($.trim($("#beginAddTime").val()));
		$('#exportexcalform input[name="endAddTime"]').val($.trim($("#endAddTime").val()));
		$('#exportexcalform input[name="diffStock"]').val($.trim($("#diffStock").val()));
		$('#exportexcalform').submit();
  		}
    
</script>
<!-- script end -->
</body>
</html>